Adding a constraint to a business object

This customization example adds an object constraint to the Campaign business object and shows the changes to the application.

1.  Open BOD. Select the Campaign object and click Edit.

2.  Select Constraints, Add, and name the constraint.

3.  For Description, enter: Description must include \”campaign\”.

Note: Using double quotes will cause errors when building the object; this demonstrates a C# quoting technique.

4.  Change Severity to “Error”.

Note: The default Trigger Events are AddNew and Update.

5.  Add this text to the Message: Description must include the word \”campaign\”.

6.  In the Code text area, copy and paste the following code:

string itemval = item.GetString("Description");

itemval = itemval.ToUpper();

if (itemval.IndexOf ("CAMPAIGN") > 0)

constraintPassed = true;

7.  Select Save, Close, Build, and Publish.

8.  In iMIS, navigate to Marketing/Campaign management, and select New Campaign.

9.  Enter a new Name and Code, leave the Description blank, and select Save. The message text from the business object will be displayed.

10. Change the Description to “Campaign description”, and the campaign can be saved without error.